<template>
    <div >
    <button @click="handleClick">{{num}}跳过</button>
    </div>
</template>

<script>
    export default {
        data(){
            return{
                num:3,
                timer:null
            }
        },
        mounted() {
            this.countReduce()
        },
        methods:{
            countReduce(){
                var num = this.num;
                this.timer = setTimeout(() => {
                    num--;
                    if(num>=0){
                        if(num == 0){
                            this.$router.push('/home')
                        }
                        this.num = num;
                        this.countReduce()
                    }
                }, 1000);
            },
            handleClick(){
                clearTimeout(this.timer)
                this.$router.push('/home')
            }
        }
    }
</script>
<style scoped>
</style>